import request from '@/utils/request'
import { M, C } from '@/api/apiPrefix'
import { download } from '@/utils/request'

export const queryProjectListApi = params => request({
    url: `/${M.business}/${C.project}/list`,
    params
})
export const queryProjectNameApi = projectName => request({
    url: `/${M.business}/${C.project}/findRepeat`,
    method: 'get',
    params: { projectName }
})
export const addProjectApi = data => request({
    url: `/${M.business}/${C.project}`,
    method: 'post',
    data
})
export const updateProjectApi = data => request({
    url: `/${M.business}/${C.project}`,
    method: 'put',
    data
})
export const updateProjectStatusApi = data => request({
    url: `/${M.business}/${C.project}/status`,
    method: 'put',
    data
})
export const delProjectApi = ids => request({
    url: `/${M.business}/${C.project}/${ids}`,
    method: 'delete'
})

export const addAnnexApi = (id, data) => request({
    url: `/${M.business}/${C.project}/importAnnex/${id}`,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
})
export const delAnnexApi = ids => request({
    url: `/${M.business}/${C.project}/annex/${ids}`,
    method: 'delete'
})
export const queryAnnexListApi = (id, params) => request({
    url: `/${M.business}/${C.project}/annex/${id}`,
    method: 'get',
    params
})
//本地下载
export const downloadAnnexApi = id => request({
    url: `/common/download/${id}`,
    responseType: 'blob',
    method: 'post'
})

//minio下载
export const downloadAnnexMinioApi = url => request({
    url,
    responseType: 'blob'
})

